<template>
    <div id="questionnaire">
        <div class="bigbox">
            <div class="sbox">
                <el-col :span="24">
                    <el-row style="margin-bottom: 20px; margin-top: 20px" class="title">
                        <el-col :span="24" :offset="2" class="header">
                            预检分诊登记表
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            1.填表日期
                            <div class="block">
                                <span class="demonstration"></span>
                                <el-date-picker
                                    v-model="date"
                                    type="date"
                                    placeholder="选择日期"
                                    @blur="judgeDate"
                                    disabled="true"
                                >
                                </el-date-picker>
                            </div>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            2.患者姓名<br>
                            <el-input placeholder="请输入内容" v-model="username"  disabled></el-input>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            3.患者身份证号<br>
                            <el-input placeholder="请输入内容" v-model="idnumber"
                                      disabled></el-input>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            4.联系电话<br>
                            <el-input placeholder="请输入内容" v-model="phone" @blur="judgePhone"></el-input>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            5.患者体温℃<br/>
                            <el-select v-model="temperature" placeholder="请选择" aria-required="true">
                                <el-option
                                    v-for="item in temp"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"

                                >
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-row>

                    <el-row>
                        <el-col>
                            6.旅居史<br/>
                            <el-select v-model="travel" placeholder="请选择" aria-required="true">
                                <el-option
                                    v-for="item in tra"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"

                                >
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            7.接触史<br/>
                            <el-select v-model="contact" placeholder="请选择" aria-required="true">
                                <el-option
                                    v-for="item in con"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                >
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            8.高风险岗位人员<br/>
                            <el-select v-model="job" placeholder="请选择" aria-required="true">
                                <el-option
                                    v-for="item in jo"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                >
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            9.十大临床症状（请根据病情选择)<br/>
                            <el-select v-model="symptom" placeholder="请选择" aria-required="true">
                                <el-option
                                    v-for="item in sym"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                >
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col>
                            10.最近一次核酸检测情况<br/>
                            <el-select v-model="nucleic" placeholder="请选择" aria-required="true">
                                <el-option
                                    v-for="item in nuc"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                >
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-row>

                </el-col>
                <el-button type="primary" @click="savetriage">提交</el-button>
            </div>

        </div>
    </div>
</template>

<script>
import axios from 'axios'

export default {
    data() {
        return {
            temp: [
                {
                    value: "小于37.3",
                    label: "小于37.3",
                },
                {
                    value: "大于或等于37.3",
                    label: "大于或等于37.3",
                },
            ],

            tra: [
                {
                    value: "有境外高风险地区旅居史（14天内）",
                    label: "有境外高风险地区旅居史（14天内）",
                },
                {
                    value: "有境内中高风险旅居史（7天内）",
                    label: "有境内中高风险旅居史（7天内）",
                },
                {
                    value: "有省市卫生行政部门发布的重点地区（县/区）旅居史（7天内）",
                    label: "有省市卫生行政部门发布的重点地区（县/区）旅居史（7天内）",
                },
                {
                    value: "以上均无",
                    label: "以上均无",
                },
            ],

            con: [
                {
                    value:
                        "有新冠病毒感染人员或病例报告社区有发热、呼吸道等症状人员接触史(7天内)",
                    label:
                        "有新冠病毒感染人员或病例报告社区有发热、呼吸道等症状人员接触史(7天内)",
                },
                {
                    value: "健康码异常人员(7天内)",
                    label: "健康码异常人员(7天内)",
                },
                {
                    value: "有聚集性发病史(2例及以上发热或呼吸道症状病例)(7天内)",
                    label: "有聚集性发病史(2例及以上发热或呼吸道症状病例)(7天内)",
                },
                {
                    value: "无以上接触史",
                    label: "无以上接触史",
                },
            ],

            jo: [
                {
                    value: "跨境交通工具司乘、保洁、维修等人员",
                    label: "跨境交通工具司乘、保洁、维修等人员",
                },
                {
                    value: "海关、移民管理部门等其他直接接触入境人员和物品的一线人员",
                    label: "海关、移民管理部门等其他直接接触入境人员和物品的一线人员",
                },
                {
                    value: "口岸进口物品搬运人员和管理服务人员",
                    label: "口岸进口物品搬运人员和管理服务人员",
                },
                {
                    value: "船舶引航员等登临外籍船舶作业人员",
                    label: "船舶引航员等登临外籍船舶作业人员",
                },
                {
                    value: "进口冷链食品、药品(含外包装)监管和从业人员",
                    label: "进口冷链食品、药品(含外包装)监管和从业人员",
                },
                {
                    value: "定点医疗机构和普通医疗机构发热门诊工作人员",
                    label: "定点医疗机构和普通医疗机构发热门诊工作人员",
                },
                {
                    value: "从事新冠病毒感染者及其他风险人群转运的急救及社区工作人员",
                    label: "从事新冠病毒感染者及其他风险人群转运的急救及社区工作人员",
                },
                {
                    value: "集中隔离医学观场所工作人员",
                    label: "集中隔离医学观场所工作人员",
                },
                {
                    value: "从事风险人群核酸采样、运送及检测人员",
                    label: "从事风险人群核酸采样、运送及检测人员",
                },
                {
                    value: "其他经风险研判确定的高风险岗位人员",
                    label: "其他经风险研判确定的高风险岗位人员",
                },
                {
                    value: "以上均不是",
                    label: "以上均不是",
                },
            ],
            sym: [
                {
                    value: "发热",
                    label: "发热",
                },
                {
                    value: "干咳",
                    label: "干咳",
                },
                {
                    value: "鼻塞",
                    label: "鼻塞",
                },
                {
                    value: "流涕",
                    label: "流涕",
                },
                {
                    value: "咽痛等呼吸道症状",
                    label: "咽痛等呼吸道症状",
                },
                {
                    value: "腹泻等消化道症状",
                    label: "腹泻等消化道症状",
                },
                {
                    value: "乏力",
                    label: "乏力",
                },
                {
                    value: "集中隔离医学观场所工作人员",
                    label: "集中隔离医学观场所工作人员",
                },
                {
                    value: "肌痛",
                    label: "肌痛",
                },
                {
                    value: "结膜炎",
                    label: "结膜炎",
                },
                {
                    value: "嗅觉味觉减退等其他症状",
                    label: "嗅觉味觉减退等其他症状",
                },
                {
                    value: "以上均不是",
                    label: "以上均不是",
                },
            ],

            nuc: [
                {
                    value: "48小时内",
                    label: "48小时内",
                },
                {
                    value: "72小时内",
                    label: "72小时内",
                },
                {
                    value: "1周内",
                    label: "1周内",
                },
                {
                    value: "1周以前",
                    label: "1周以前",
                },
                {
                    value: "未检测过",
                    label: "未检测过",
                },
            ],

            temperature: "",
            travel: "",
            contact: "",
            job: "",
            symptom: "",
            nucleic: "",
            date: "",
            username: "",
            idnumber: "",
            phone: "",

        };
    },
    methods: {
        savetriage: function () {
            if (this.nucleic=="" || this.symptom=="" || this.job=="" || this.contant=="" || this.travel=="" || this.temperature==""){
                this.$message({
                    message: "请完整填写表单信息",
                    type: "error",
                    duration:2000
                })
                return;
            }
            var that = this;
            axios.post("http://localhost:8848/saveTriage", {
                date: that.date,
                username: that.username,
                idnumber: that.idnumber,
                phone: that.phone,
                temperature: that.temperature,
                travel: that.travel,
                contact: that.contact,
                job: that.job,
                symptom: that.symptom,
                nucleic: that.nucleic
            })
                .then(function (response) {
                    console.log(response);
                })

            this.$notify({
                title: "添加信息成功，请你尽快付款",
                type: "success",
                duration: 2000,
            })
            this.$router.push({
                path: "8-8",

            })
        },
        judgeName: function () {
            if (this.username == "" || this.username == null) {
                alert("用户名不能为空");
            }
        },
        judgePhoneNo(phoneNo) {
            var reg = /^1[3-9][0-9]\d{8}$/;
            return reg.test(phoneNo);
        },
        judgeIdNo(idNo) {
            var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            return reg.test(idNo);
        },
        judgePhone: function () {
            if (this.phone == "" || this.phone == null) {
                alert("电话不能为空");
            } else if (!this.judgePhoneNo(this.phone)) {
                alert("手机号码格式错误");
            }
        },
        judgeDate: function () {
            if (this.date == "" || this.date == null) {
                alert("日期不能为空");
            }
        },
        judgeIdNumber: function () {
            if (this.idnumber == "" || this.idnumber == null) {
                alert("身份证号不能为空");
            } else if (!this.judgeIdNo(this.idnumber)) {
                alert("身份证号码格式错误");
            }
        },
        judgeTemperature: function () {
            if (this.temperature == "" || this.temperature == null) {
                alert("体温不能为空");
            }
        },
        judgetravel: function () {
            if (this.travel == "" || this.travel == null) {
                alert("旅居史不能为空");
            }
        },
        judgecontact: function () {
            if (this.contact == "" || this.contact == null) {
                alert("接触史不能为空");
            }
        },
        judgejob: function () {
            if (this.job == "" || this.job == null) {
                alert("接触史不能为空");
            }
        },
        judgesymptom: function () {
            if (this.symptom == "" || this.symptom == null) {
                alert("临床症状不能为空");
            }
        },
        judgenucleic: function () {
            if (this.ucleic == "" || this.ucleic == null) {
                alert("最近一次核酸情况不能为空");
            }
        }

    },
    comments: {},
    mounted() {
        this.username = this.$store.state.currentUser.username;
        this.idnumber = this.$store.state.currentUser.idnumber;
        this.phone = this.$store.state.currentUser.phone;
        this.date = new Date();
    }
};
</script>

<style scoped>
.el-input {
    width: 40%;
    margin-top: 15px;
    margin-bottom: 20px;
}

.el-select {
    width: 40%;
    margin-top: 15px;
    margin-bottom: 20px;
}

.title {
    font-size: 30px;
    margin-left: 20px;
}

.bigbox {
    height: 1100px;
}

.sbox {
    margin-left: 36%;
}

.el-button {
    width: 390px;
}
</style>
